import { http } from '@/utils/request'

export const addProductApi = (data: FormData) => {
    return http.post('/adminapi/product/add', data, {
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
}

export const getProductListApi = (id?: string) => {
    if (id) {
        return http.get(`/adminapi/product/list/${id}`)
    }
    return http.get(`/adminapi/product/list/all`)
}

export const deleteProductApi = (id: number) => {
    return http.delete(`/adminapi/product/delete/${id}`)
}

export const editProductApi = (data: FormData) => {
    return http.post('/adminapi/product/edit', data, {
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
}